<%@page import="com.drerp.RH.Colaborador"%>
<%@page import="com.drerp.RH.Contrato"%>
<%@page import="com.drerp.RH.Cargo"%>

<%@page import="java.util.List"%>  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="StyleSheet" href="../styles.css" type="text/css" media=screen />


<script type="text/javascript">
	function abrir_pop_up(url) {
		window.open(url, "Editar Foto", "status = 0, height = 420, width = 800, resizable = 0, scrollbars = 1");
	}
</script>

<title>Editar Colaborador</title>

</head>
<body>

<% 
	long func_id = Long.parseLong(request.getParameter("id"));
	Colaborador func = Colaborador.encontrarColaboradorPorId(func_id);
	int dia = func.getDia_nascimento();
	int mes = func.getMes_nascimento();
	int ano = func.getAno_nascimento();
	List<Contrato> contratos = func.getContratos();
%>

<jsp:include page="/nav/header.jsp" />

<div class="body">
	
	<jsp:include page="/nav/menu.jsp" />
	
	<div class="center">
	
		<h1>Editar Colaborador</h1>
		
		<form action="salvar.jsp" method="post">
			<div class="inner_center">
				<div class="title" style="width: 140px;">Dados Pessoais</div>
				
					<div style="float: left; margin: 20px; width: 40%">
						<input type="hidden" name="func_id" value="<%=func_id%>">
						
						<table style="border-width: 0px; width: 100%;">
							<tr>
								<td colspan="2">
									<label>Nome:</label><br />
									<input type="text" name="nome" value="<%= func.getNome() == null? "" : func.getNome() %>"/>
								</td>
							</tr>
							
							<tr>
								<td colspan="2">
									<label>Data de Nascimento:</label><br />
									<select name="dia_nascimento"> 
									<%for(int i=1;i<32;i++){%>
										<option <%= i==dia? "selected" :""%>><%=i%>
									<%}%>
									</select> 
									<select name="mes_nascimento"> 
									<%for(int i=1;i<13;i++){%>
										<option <%= i==mes? "selected" :""%>><%=i%>
									<%}%>
									</select> 
									<select name="ano_nascimento"> 
									<%for(int i=2011;i>1900;i--){%>
										<option <%= i==ano? "selected" :""%>><%=i%>
									<%}%>
									</select>
								</td>
							</tr>
							
							<tr>
								<td colspan="2">
									<label>Endere&ccedil;o:</label><br />
									<input type="text" name="endereco" value="<%= func.getEndereco() == null? "" : func.getEndereco()%>"/>
								</td>
							</tr>
							
							<tr>
								<td>
									<label>Tel. Residencial:</label><br />
									<input type="text" name="tel" value="<%= func.getTelefone() == null? "" : func.getTelefone()%>"/>
								</td>
								<td>
									<label>Tel. Celular:</label><br />
									<input type="text" name="tel_cel" value="<%= func.getTel_celular() == null? "" : func.getTel_celular()%>"/>
								</td>
							</tr>
							
							<tr>
								<td>
									<label>RG:</label><br />
									<input type="text" name="rg" value="<%= func.getRg_numero() == null? "" : func.getRg_numero() %> "/>
								</td>
								<td>
									<label>CPF:</label><br />
									<input type="text" name="cpf" value="<%= func.getCpf() == null? "" : func.getCpf() %>"/>
								</td>
							</tr>
							
							<tr>
								<td colspan="2">
									<label>Carteira de trabalho:</label><br />
									<input type="text" name="ctps" value="<%= func.getCtps_numero() == null? "" : func.getCtps_numero()%>"/>
								</td>
							</tr>
						</table>
					</div>
					
					<div style="margin-left: 20px; float: left;">
						<img src="foto?id=<%= func_id %>" /><br />
						<a href="#" onclick="return abrir_pop_up('edita_foto.jsp?id=<%= func_id %>');">Editar foto</a>
					</div>
			</div>
			
			<div class="inner_center">
				<div class="title" style="width: 170px;">Dados Contratuais</div>
				
					<div style="margin: 30px;">
						<label>Cargo:</label>
						<select name="cargo_id">
						<% for (Cargo cargo : Cargo.encontraTodosCargos()) { %>
							<option value="<%= cargo.getCargo_id() %>"
							<%= (func.getCargo() != null && cargo.getCargo_id() == func.getCargo().getCargo_id()) ? "selected=\"selected\"" : "" %>>
								<%= cargo.getNome() %>
							</option>		
						<% } %>
						</select>
					</div>
					
				</div>
			</div>
			
			<br />
			<div style="float: right; margin: 10px 20px;">
				<input type="submit" class="button" value="Salvar" />&nbsp;&nbsp;|&nbsp;&nbsp;<a href="lista.jsp">Voltar</a>
			</div>
		</form>
		
	</div>
	
</div>

</body>
</html>